<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" />
		<link rel="stylesheet" href="css/Site.css" />
		<link rel="stylesheet" href="css/zy.all.css" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />
		<link rel="stylesheet" href="css/amazeui.min.css" />
		<link rel="stylesheet" href="css/admin.css" />
	</head>

	<body>
			<div style="margin: 30px;" >
				<form action="/user_page_list" method="post">
					<input type="text" placeholder="输入移动电话" style="font-size: 25px;" name="userphone"/>
					<input type="submit" value="搜索" />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="text" placeholder="输入用户姓名" style="font-size: 25px;" name="username"/>
					<input type="submit" value="搜索" />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<span style="font-size: 25px;">分类查询</span>
					
					<select  th:if="${roleList ne null}" style="font-size: 25px;" name="role_id" >
						<option value="0" >---请选择---</option>
						<option value="-1">查询所有</option>
						<option th:each="role:${roleList}" th:value="${role.role_id}" th:text="${role.role_name}"></option>
					</select>
					<input type="submit" value="搜索" />
				</form>
			</div>
			
				<!--tab start-->
					<div class="hd">
						<ul>
							<li class="on" style="box-sizing: initial;-webkit-box-sizing: initial;">查看用户</li>
						</ul>
					</div>
					<div class="bd">
						<ul style="display: block;padding: 20px;">
							<li>
								<!--分页显示角色信息 start-->
								<div id="dv1">
								<form action="#" method="post">
									<table class="table" id="tbRecord">
										<thead>
											<tr>
												<th>编号</th>
												<th>姓名</th>
												<th>移动电话</th>
												<th>权限</th>
												<th>余额</th>
												<th>状态</th>
												<!-- <th>修改</th> -->
											</tr>
										</thead>
										<tbody>
											<tr th:if="${userpage} ne null" th:each="u:${userpage.getResult()}">
												<td th:text="${u.user_id}"></td>
												<td th:text="${u.user_name}"></td>
												<td th:text="${u.user_phone}"></td>
												<td th:text="${u.role.role_name}"></td>
												<td th:text="${u.user_capital}"></td>
												<td th:if="${u.role.permissions.permissions_state} eq 1" class="per_state">
													<input type="radio"  th:name ="${u.user_id}" checked="checked" class="per_state_val" value="1"> 不可用
													<input type="radio"  th:name ="${u.user_id}" class="per_state_val" value="2">  可用
												</td> 
												<td th:if="${u.role.permissions.permissions_state} eq 2" class="per_state">
													<input type="radio"  th:name ="${u.user_id}"  class="per_state_val" value="1"> 不可用
													<input type="radio"  th:name ="${u.user_id}"checked="checked"  class="per_state_val"value="2">  可用
												</td>
												<!-- <td th:text="${u.role.permissions.permissions_state}"></td> -->
												<!-- <td class="edit"> 
													<a th:href="@{/user_update(userid=${u.user_id},user_name=${u.user_name})}"><button onclick="btn_edit(1)"><i class="icon-edit bigger-120"></i>编辑</button></a>
												</td> -->
											</tr>
											<tr th:if="${userpage} eq null" >
												<td th:text="1"></td>
												<td th:text="李四"></td>
												<td th:text="13785465421"></td>
												<td th:text="普通用户"></td>
												<td th:text="5000"></td>
												<td >
													<input type="radio" name="1" checked="checked" class="per_state_val" value="1"> 不可用
													<input type="radio" name="1" class="per_state_val" value="2">  可用
												</td> 
											</tr>
										</tbody>

									</table>
								</form>
									
									<span th:if="${userpage.getPageNum()>1}">
										<a th:href="@{/user_page_list(
										pageNum=1,
										userphone=${userphone},
										role_id=${role_id}
										)}">首页</a>
										<a th:href="@{/user_page_list(
										pageNum=${userpage.getPageNum()-1},
										userphone=${userphone},
										role_id=${role_id}
										)}">上一页</a>
									</span>
									<span th:if="${userpage.getPageNum()<userpage.getPages()}">
										<a th:href="@{/user_page_list(
										pageNum=${userpage.getPageNum()+1},
										userphone=${userphone},
										role_id=${role_id}
										)}">下一页</a>
										<a th:href="@{/user_page_list(
										pageNum=${userpage.getPages()},
										userphone=${userphone},
										role_id=${role_id}
										)}">尾页</a>
									</span>&nbsp;&nbsp;&nbsp;&nbsp;
									<p>
										第<span th:text="${userpage.getPageNum()}"></span>页，总数 
										<span th:text=" ${userpage.getTotal()}"></span>条
									</p>
									
								</div>
								
								<!--分页显示角色信息 end-->
							</li>
						</ul>
								<script src="./js/jquery-1.7.2.min.js" ></script>
								<script src="./js/plugs/Jqueryplugs.js"></script>
								<script src="./js/_layout.js"></script>
								<script src="./js/jquery.js"></script>
								<script src="./js/plugs/jquery.SuperSlide.source.js"></script>
								<script type="text/javascript">
								
									$(function() {
										//修改用户可用不可用
										 $(".per_state_val").click(function(){
											var $per_stat=$(this).val();//当前per——start的值
											var $userid=$(this).parent().parent().children(":first").text();
											var data = "userid="+$userid+"&per_stat="+$per_stat;
											$.ajax({
												type:'POST',
												dataType:"json",
												url:'/user_update_save',
												data:data,
												success:function(data){//返回json结果
													if(data.data=="success"){
														alert("修改成功");
													}else if(data.data=="errors"){
														alert("修改失败");
													}
												},
												error:function(data){
											        //请求出错处理
											        alert("出现异常");
											    }
											})
										})	 

									})
								
								</script>
							</div>
	</body>

</html>